/*
 * @Description: 用户模块
 * @Author: Yong
 * @Date: 2021-09-29 14:50:28
 * @LastEditTime: 2021-10-06 15:59:30
 */
import { Provide, Controller, Post, Inject, Body, ALL } from '@midwayjs/decorator'
import { UserInfo } from '../interface'
import { UserService } from '../service/User'
import { Context } from '@midwayjs/koa'
@Provide()
@Controller('/user')
export class UserController {

    @Inject()
    ctx: Context

    @Inject()
    userService: UserService

    /**
     * 注册
     */
    @Post('/register')
    async register (@Body(ALL) userInfo: UserInfo) {
        
        await this.userService.addUser(userInfo)
    }

    /**
     * 登录
     */
    @Post('/login')
    async login (@Body(ALL) userInfo: UserInfo) {
        await this.userService.login(userInfo)
    }

    /**
     * 模糊搜索所有用户 
     */
    @Post('/searchUser')
    async searchUser (@Body(ALL) searchParam: any) {
        console.log('searchParam==>', searchParam);
        
        await this.userService.searchUser(searchParam.searchName, searchParam.userID)
    }
}